package com.novanok.chaincollaboration;

import android.app.Activity;
import android.net.nsd.NsdServiceInfo;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

/**
 * Created by Marcos on 21/09/2014.
 */
public class NewCollaboration extends Activity {

    private NsdHelper mNsdHelper;
    private ChatConnection mConnection;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.new_collaboration);

        // this.mNsdHelper = MainActivity.getMNsdHelper();
        // this.mConnection  = MainActivity.getChatConnection();
    }

    public void sendNewCollaboration (View v){
        connect();
        sendMessage();
    }

    private void connect(){
        NsdServiceInfo service = mNsdHelper.getChosenServiceInfo();
        if (service != null) {
            Log.d(MainActivity.TAG, "Connecting.");
            mConnection.connectToServer(service.getHost(),
                    service.getPort());
        } else {
            Log.d(MainActivity.TAG, "No service to connect to!");
        }
    }

    private void sendMessage(){
        mConnection.sendMessage("Nueva Collaboration");
    }
}
